<template>
	<view>
		<view class="navbar" :style="{ width: navbarMessage.width, height: navbarMessage.height, paddingTop: navbarMessage.paddingTop, paddingRight: navbarMessage.paddingRight,backgroundColor: bgc }">
			<view class="left-icon" v-if="showMenu">
				<image :src="iconColor == 'white' ? '/static/images/menu-w.png' : '/static/images/menu-b.png'" mode="widthFix"></image>
			</view>
			<view class="left-icon" v-if="showBack" @click="back">
				<image :src="iconColor == 'white' ? '/static/images/back-w.png' : '/static/images/back-b.png'" mode="widthFix"></image>
			</view>
			<view class="left-icon" v-if="showDown" @click="back">
				<image :src="iconColor == 'white' ? '/static/images/down-w.png' : '/static/images/down-b.png'" mode="widthFix"></image>
			</view>
				<slot></slot>
			<!-- <view class="right-icon" v-if="showDown" @click="back">
				<image :src="iconColor == 'white' ? '/static/images/down-w.png' : '/static/images/down-b.png'" mode="widthFix"></image>
			</view> -->
		</view>
		
		<!-- 占位元素，用以设置navbar是否占用文档流，若显示则占用,默认占用 -->
		<view class="isDocument" v-if="isDocument" :style="{ height: navbarMessage.height }">

		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		name: 'navbar',
		props: {
			showMenu: {
				type: Boolean,
				default: true
			},
			showBack: {
				type: Boolean,
				default: false
			},
			showDown: {
				type: Boolean,
				default: false
			},
			isDocument: {
				type: Boolean,
				default: true
			},
			bgc: {
				type: String,
				default: 'transparent'
			},
			iconColor: {
				type: String,
				default: 'white'
			}
		},
		data() {
			return {

			};
		},
		computed: {
			...mapState(['navbarMessage'])
		},
		methods: {
			back() {
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style lang="less">
	.navbar {
		position: fixed;
		display: flex;
		// justify-content: space-between;
		align-items: center;
		padding-left: 20rpx;
		z-index: 10000;
		.left-icon {
			width: 40rpx;
			margin-right: 20rpx;
			image {
				width: 40rpx
			}
		}
		
		.content {
		}
		
		.right-icon {
			position: absolute;
			right: 0;
			width: 40rpx;
			margin-right: 20rpx;
			image {
				width: 40rpx
			}
		}
	}
	
	.isDocument {	//占位元素，用以设置navbar是否占用文档流，若显示则占用
		width: 750rpx;
	}
</style>
